package CreationalPattern.Singleton.LazySingleton;


// 双重检查锁
public class LazySingleton {
    private volatile static LazySingleton instance = null;

    private LazySingleton(){}

    public static LazySingleton getInstance() {
        // 第一重判断
        if (instance == null) {
            synchronized (LazySingleton.class) {
                // 第二重判断
                if (instance == null) {
                    instance = new LazySingleton();
                }
            }
        }
        return instance;
    }
}
